﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CC98.Data;
using CC98.Network;
using CC98.Network.Primitives;

namespace CC98
{
    public class CC98Client
    {
        internal CC98Client(CC98HttpClient httpClient)
        {
            this.HttpClient = httpClient;
            this.HttpClient.AuthenticationStateChanged += OnAuthenticationStateChanged;
        }

        public User User { get; private set; }

        public bool? IsAuthenticated
        {
            get
            {
                return this.HttpClient.IsAuthenticated;
            }
        }

        public event EventHandler<AuthenticationStateChangedEventArgs> AuthenticationStateChanged;

        protected CC98HttpClient HttpClient { get; private set; }

        protected void OnAuthenticationStateChanged(object sender, AuthenticationStateChangedEventArgs e)
        {
            var eventHandler = this.AuthenticationStateChanged;
            if (eventHandler != null)
                eventHandler(this, e);
        }
    }
}
